package com.fcy.dialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity implements MyListDialogBuilder.OnClickListener {

    private Dialog dialog;

    String data[] = {"你好", "系统", "SIM卡", "走吧", "英雄联盟测试加长的显示效果，快点加长啊，快点继续加长"
            , "你好", "系统", "SIM卡", "走吧", "英雄联盟", "水煮三国", "斗牛士"};

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

    public void onAlertClick(View view) {
        new AlertDialog.Builder(this)
                .setTitle("系统的AlertDialog")
                .setItems(data, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你点击了: " + data[which], Toast.LENGTH_SHORT).show();
                    }
                })
                .setNegativeButton("取消", null)
                .setPositiveButton("确定", null)
                .create().show();
    }

    public void onSingleClick(View view) {
        new MyDialogBuilder(this, "警告", "确定退出应用么？")
                .setPositiveButton("呜呜---", new MyDialogBuilder.OnClickListener() {
                    @Override
                    public void onClick() {
                        Toast.makeText(MainActivity.this, "主人不要我了~~~", Toast.LENGTH_SHORT).show();
                    }
                })
                .setNegativeButton("逗你玩", null)
                .create().show();
    }

    public void onWrapClick(View view) {
        new MyListDialogBuilder(
                this, MyListDialogBuilder.STYLE_DIALOG_HEIGHT_WRAP, "高度包裹的列表", data)
                .setItemsListener(this)
                .create().show();
    }

    public void onFixedClick(View view) {
        new MyListDialogBuilder(
                this, MyListDialogBuilder.STYLE_DIALOG_HEIGHT_FIXED, "高度固定的列表", data)
                .setItemsListener(this)
                .create().show();
    }


    @Override
    public void onDialogItemClick(int witch) {
        Toast.makeText(this, "你点击了: " + data[witch], Toast.LENGTH_SHORT).show();
    }
}
